﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="RentCar.aspx.cs" Inherits="Employee_Rent_RentCar" %>

    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        .style1
        {
            width: 264px;
        }
        .style2
        {
            width: 54px;
        }
        .style3
        {
            width: 80%;
        }
        .style4
        {
            width: 30%;
            margin-left: 40px;
        }
        .style5
        {
            height: 29px;
        }
        .style6
        {
            width: 30%;
            margin-left: 40px;
            height: 29px;
        }
        .style7
        {
            height: 62px;
        }
        .style8
        {
            width: 30%;
            margin-left: 40px;
            height: 62px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <p>
        Find Car:</p>
    <table class="style1">
        <tr>
            <td class="style2">
                Brand
                :</td>
            <td>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
                    DataTextField="brand" DataValueField="brand">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MySqlConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:MySqlConnectionString.ProviderName %>" SelectCommand="Select distinct brand from car;">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style2">
                Make
                :</td>
            <td>
                <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource2"
                    DataTextField="make" DataValueField="make" >
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MySqlConnectionString %>"
                    ProviderName="<%$ ConnectionStrings:MySqlConnectionString.ProviderName %>" SelectCommand="select distinct make from car where brand=@brand;">
                    <SelectParameters>
                        <asp:ControlParameter Name="brand" ControlID="DropDownList1" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style2">
                &nbsp;</td>
            <td>
                <asp:Button ID="Search" runat="server" onclick="Search_Click" Text="Search" />
            </td>
        </tr>
        </table>
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="plate_no,car_id"
            DataSourceID="SqlDataSource3" EnableModelValidation="True" 
            AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="Black" 
            GridLines="Vertical" 
            onselectedindexchanged="GridView1_SelectedIndexChanged" BackColor="White" 
            BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="car_id" HeaderText="Car ID" ReadOnly="True" SortExpression="car_id" />
                <asp:BoundField DataField="plate_no" HeaderText="Plate No" ReadOnly="True" SortExpression="plate_no" />
                <asp:BoundField DataField="brand" HeaderText="Brand" SortExpression="brand" />
                <asp:BoundField DataField="make" HeaderText="Make" SortExpression="make" />
                <asp:BoundField DataField="color" HeaderText="Color" SortExpression="color" />
                <asp:BoundField DataField="speed" HeaderText="Speed" SortExpression="speed" />
                <asp:BoundField DataField="tariff" HeaderText="Tariff" SortExpression="tariff" />
            </Columns>
            <FooterStyle BackColor="#CCCC99" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <RowStyle BackColor="#F7F7DE" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:MySqlConnectionString %>"
            ProviderName="<%$ ConnectionStrings:MySqlConnectionString.ProviderName %>" SelectCommand="SELECT plate_no, brand, car_id, make, color, speed, tariff FROM car WHERE availability=1;">
        </asp:SqlDataSource>
    </p>
    <table class="style3">
        <tr>
            <td colspan="4" style="font-weight: 700">
                <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ControlToValidate="CarID" ErrorMessage="No car selected"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Car ID:</td>
            <td class="style4">
                <asp:TextBox ID="CarID" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td>
                Insurance:</td>
            <td>
                <asp:DropDownList ID="Insurance" runat="server" 
                    DataSourceID="SqlDataSource4" DataTextField="type" 
                    DataValueField="insurance_id" >
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:MySqlConnectionString %>" 
                    ProviderName="<%$ ConnectionStrings:MySqlConnectionString.ProviderName %>" 
                    SelectCommand="SELECT type, insurance_id FROM insurance;">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                Plate Number: </td>
            <td class="style4">
                <asp:TextBox ID="PlateNumber" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td>
                License Number:</td>
            <td>
                <asp:TextBox ID="LicenseNo" runat="server" 
                    ontextchanged="LicenseNo_TextChanged" AutoPostBack="True"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ErrorMessage="Enter License Number" ControlToValidate="LicenseNo"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style5">
                Brand:</td>
            <td class="style6">
                <asp:TextBox ID="Brand" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style5">
                Start Date:</td>
            <td class="style5">
                <asp:TextBox ID="StartDate" runat="server"></asp:TextBox>
                <asp:CalendarExtender ID="StartDate_CalendarExtender" runat="server" 
                    TargetControlID="StartDate" DefaultView="Years" Format="yyyy/MM/d">
                </asp:CalendarExtender>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ErrorMessage="Start Date Required" ControlToValidate="StartDate"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style7">
                Make:</td>
            <td class="style8">
                <asp:TextBox ID="Make" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td class="style7">
                Return Date:</td>
            <td class="style7">
                <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
                </asp:ToolkitScriptManager>
                <asp:TextBox ID="ReturnDate" runat="server"></asp:TextBox>
                <asp:CalendarExtender ID="ReturnDate_CalendarExtender" runat="server" 
                    TargetControlID="ReturnDate" DefaultView="Years" Format="yyyy/MM/d">
                </asp:CalendarExtender>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ErrorMessage="End Date Required" ControlToValidate="ReturnDate"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Color:</td>
            <td class="style4">
                <asp:TextBox ID="Color" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                Speed:</td>
            <td class="style4">
                <asp:TextBox ID="Speed" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                Tariff:</td>
            <td class="style4">
                <asp:TextBox ID="Tariff" runat="server" ReadOnly="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" align=right>
                <asp:Button ID="Book" runat="server" Text="Book" onclick="Book_Click" />
            </td>
            <td colspan="2">
                <asp:Button ID="Cancel" runat="server" Text="Cancel" />
            </td>
        </tr>
    </table>
</asp:Content>
